
<%@ page import="com.bafa.objects.*" %>
<%@ page import="java.util.*" %>
<% 
Season createdSeason = (Season)request.getAttribute("CREATEDSEASON");
Team[] teams = (Team[])request.getAttribute("TEAMS");
HashMap addedTeams = (HashMap)session.getAttribute("ADDEDTEAMS");
if(addedTeams==null) addedTeams=new HashMap();
 %>
 <%SiteBean siteBean = (SiteBean)session.getAttribute("SITEBEAN");%>

<style type="text/css">

#Main {
	position:relative;
	width:701px;
	height:551px;
	z-index:1;
}
#Layer1 {
	position:absolute;
	width:252;
	height:115px;
	z-index:1;
	left: 0;
	top: 0;
}
#Layer2 {
	position:absolute;
	width:252;
	height:22;
	z-index:1;
}

-->
</style>
<link href="styles_5.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer3 {
	position:absolute;
	width:252;
	height:115px;
	z-index:2;
	top: 22;
}
#Layer4 {
	position:absolute;
	width:252;
	height:115px;
	z-index:2;
	top: 200;
}

#Rules {
	position:absolute;
	width:252;
	height:115px;
	z-index:2;
	top: 350;
}

#Layer5 {
	position:absolute;
	width:252;
	height:22;
	z-index:1;
}
#Layer6 {
	position:absolute;
	width:252;
	height:115px;
	z-index:2;
	top: 22;
}
-->
</style>
<link href="stats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer7 {
	position:absolute;
	width:300;
	height:115px;
	z-index:3;
	left: 350;
}
#Layer8 {
	position:absolute;
	width:300;
	height:22;
	z-index:1;
}
#Layer9 {
	position:absolute;
	width:300;
	height:115px;
	z-index:2;
	top: 22;
}
-->
</style>
<div id="Main">
  <div id="Layer1">
    <div class="avlh" id="Layer2">Season Details </div>
    <div id="Layer3">
      <table width="252" border="0" class="bafatablesmall">
	  <form name="seasonform" action="createseason.bafa" method="post">
        <tr class="r2">
          <td><strong>Season</strong></td>
         <%if(createdSeason!=null){%>
		  <td><%=createdSeason.getSeason()%></td>
		 <%}else{%>
		  <td><input type="text" name="season" size="10" /></td>
		 <%}%>
		</tr>
        <tr class="r1">
          <td><strong>Year</strong></td>
          <%if(createdSeason!=null){%>
		  <td><%=createdSeason.getYear()%></td>
		 <%}else{%>
		  <td><input type="text" name="year" size="4" /></td>
		 <%}%>
        </tr>
        <tr class="r2">
          <td><strong>Cup</strong></td>
          <%if(createdSeason!=null){%>
		  <td><%if(!createdSeason.isLeague()){%>True<%}else{%>False<%}%></td>
		 <%}else{%>
		  <td><input type="radio" name="cupLeague" value="Cup" ></td>
		 <%}%>
        </tr>
        <tr class="r1">
          <td><strong>League</strong></td>
           <%if(createdSeason!=null){%>
		  <td><%if(!createdSeason.isLeague()){%>False<%}else{%>True<%}%></td>
		 <%}else{%>
		  <td><input type="radio" name="cupLeague" value="League" ></td>
		 <%}%>
        </tr>
        <tr class="r2">
          <td><strong>Number of divisions </strong></td>
          <%if(createdSeason!=null){%>
		   <td><%=createdSeason.getDivisions().size()%></td>
		  <%}else{%>
		   <td><input type="text" name="divisions" size="2" ></td>
		 <%}%>
        </tr>
        <tr class="r1">
          <td><strong>Switch On </strong></td>
           <%if(createdSeason!=null){%>
		   <td><%=createdSeason.isSwitchedOn()%></td>
		  <%}else{%>
		   <td><input type="checkbox" name="switchOn" value="switchOn" ></td>
		 <%}%>
        </tr>
		  <tr class="r2">
          <%if(createdSeason!=null){%>
		   <td colspan=2></td>
		  <%}else{%>
		   <td><input type="submit"  value="Create Season" ></td>
		 <%}%>
        </tr>
		</form>
      </table>
    </div>
  </div>

  <div id="Layer4">
    <div class="avlh" id="Layer5">Divisions</div>
    <div id="Layer6">
      <table width="252" border="0" class="bafatablesmall">
	  <%if(createdSeason!=null){%>
	  <%for(int i=0;i<createdSeason.getDivisions().size();i++){
	  Division division = (Division)createdSeason.getDivisions().get(i+1);String rowClass="";if(i%2==0) rowClass = "r2";
  	else rowClass = "r1";
	  %>
        <tr class="<%=rowClass%>">
          <td>Division <%=division.getDivision()%></td>
          <td><%=division.getTeams().size()%></td>
        </tr>
	<%}%>
	<%}%>
      </table>
    </div>
  </div>
  <%if(createdSeason!=null){%>
  <div id="Layer7">
    <div class="avlh" id="Layer8">Add a team to a division </div>
    <div id="Layer9">
      <table width="252" border="0" class="bafatablemedium">
	  <%for(int i=0;i<teams.length;i++){Team team = teams[i];String rowClass="";if(i%2==0) rowClass = "r2";
  	else rowClass = "r1";%>
        <tr class="<%=rowClass%>">
          <td><%=team.getName()%></td>
		  <%if(addedTeams.containsKey(team.getID())){%><td><b><%=addedTeams.get(team.getID())%></b></td><%}else{%>
		  <%for(int j=0;j<createdSeason.getDivisions().size();j++){Division division = (Division)createdSeason.getDivisions().get(j+1);
	  	  %>
          <td><a href="addteamtoseason.bafa?TeamId=<%=team.getID()%>&SeasonId=<%=createdSeason.getID()%>&Division=<%=j+1%>"><b><%=division.getDivision()%><b></a></td>
		  <%}%><%}%>
        </tr>
		<%}%>
      </table>
    </div>
  </div>
  <%}%>
  
  <%if(createdSeason!=null){%>
  <div id="Rules">
  
      <div class="avlh" id="Layer5">Rules</div>
      <div id="Layer6">
        <table  border="0" class="bafatablesmall">
  	  <%if(createdSeason!=null){%>
  	   <tr>
	      <td><strong>Division</strong></td>
	      <td><strong>Promoted</strong></td>
	      <td><strong>Relegated</strong></td>
	      <td><strong>Play each team</strong></td>
	      
          </tr>
  	  <%for(int i=0;i<createdSeason.getDivisions().size();i++){
  	  Division division = (Division)createdSeason.getDivisions().get(i+1);String rowClass="";if(i%2==0) rowClass = "r2";
    	else rowClass = "r1";
  	  %>
  	 <form name="rules<%=i%>" action="adddivisionrules.bafa">
  	 <input type="hidden" name="seasonId" value="<%=createdSeason.getID()%>"/>
  	 <input type="hidden" name="divisionId" value="<%=i+1%>"/>
          <tr class="<%=rowClass%>">
            <td><%=division.getDivision()%></td>
            <td><input type="text" size="2" name="promoted"/></td>
            <td><input type="text" size="2" name="relegated"/></td>
            <td><input type="text" size="2" name="playEach"/> <img src="o.gif" width="20"><a href="javascript:rules<%=i%>.submit()"><img src="next.gif" border=0 alt="Submit Rules"/></a></td>
          </tr>
          </form>
         <%}%>
  	<%}%>
  	
        </table>
      </div>
  
  </div>
   <%}%>
</div>
